# Maintainer: Daniel M. Capella <polyzen@archlinux.org>

pkgname=python-dkim
pkgver=1.1.5
pkgrel=1
pkgdesc='Python library that implements DKIM and ARC email signing and verification'
arch=('any')
url=https://launchpad.net/dkimpy
license=('ZLIB')
depends=('python-dnspython')
makedepends=(
  'python-build'
  'python-installer'
  'python-setuptools'
  'python-wheel'
)
checkdepends=('python-authres' 'python-pynacl')
optdepends=('python-aiodns' 'python-authres' 'python-pynacl')
source=("https://files.pythonhosted.org/packages/source/d/dkimpy/dkimpy-$pkgver.tar.gz")
sha256sums=('9a667f8664b72eb9f8aa1250b0757cc3982ab68f70c48af39317b58cf62f2d75')
b2sums=('d4b192a08469be678b5f08cdf2a582ec5cbd4ada56a02de011c372518a3c863e2fea1976af507a1d202f6a36f9ccef8621ba882f542e26ba22acc2f64daaf735')

build() {
  cd dkimpy-$pkgver
  python -m build --wheel --skip-dependency-check --no-isolation
}

check() {
  cd dkimpy-$pkgver
  python -m unittest dkim.tests.test_suite
}

package() {
  cd dkimpy-$pkgver
  python -m installer --destdir="$pkgdir" dist/*.whl

  # Symlink license file
  local site_packages=$(python -c "import site; print(site.getsitepackages()[0])")
  install -d "$pkgdir"/usr/share/licenses/$pkgname
  ln -s "$site_packages"/dkimpy-$pkgver.dist-info/LICENSE \
    "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
}
